Zero field counter between records. Cures bounds violation when more
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 7 Mar 2003 06:13:09 +0000 (06:13 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 7 Mar 2003 06:13:09 +0000 (06:13 +0000)
than about 50 records are shot in.

gpsbabel/gcdb.c

index 2dd5c7cd8d190cffbc9901c30eae73e83ac3bb20..74be7d46a7e5d7016ae1dbf7745b03d2e3d05680 100644 (file)
@@ -210,6 +210,7 @@ gcdb_add_to_rec(struct dbrec *rec, char *fldname, gcdb_rectype rectype, void *da
                memcpy(&rec->dbfld[rec_cnt],tbuf, length);
                tbufp = tbuf;
                length += 4 + sizeof(struct dbfld) * rec_cnt;
+               rec_cnt = 0;
                return length;
        }
 
@@ -252,7 +253,7 @@ gcdb_write_wpt(const waypoint *wpt)
         * We don't really know how many fields we'll have or how long
         * they'll be so we'll just lazily create a huge place to hold them.
         */
-       rec = xcalloc(sizeof(*rec) + 5000, 1);
+       rec = xcalloc(sizeof(*rec) + 500, 1);
 
        gcdb_add_to_rec(rec, "gcna", RECTYPE_TEXT, wpt->description);
        gcdb_add_to_rec(rec, "gcid", RECTYPE_TEXT, wpt->shortname);